<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>添加角色</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/pingTai/pingTai.css">
		<script src="${pageContext.request.contextPath}/js/utils.js" type="text/javascript" language="javascript"></script>
		<SCRIPT type="text/javascript" language="javascript"  src="${pageContext.request.contextPath}/js/jquery-1.7.2.js"></SCRIPT>
	</head>
	<body>

		<table width="100%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td height="3"></td>
			</tr>
			<tr height="20" valign="baseline">
				<td bgcolor="#353c44">
					<img src="${pageContext.request.contextPath}/images/pingTai/tb.gif"
						width="14" height="14" />
					<span class="STYLE1">添加角色</span>
				</td>
				<td align="right" bgcolor="#353c44">
					<span class="STYLE1"> </span>
				</td>
			</tr>
			<tr>
				<td height="3" colspan="2"></td>
			</tr>
		</table>

		<form
			action="${pageContext.request.contextPath}/admin/role/add"
			method="post" id="_form">
			<table width="100%" border="0" cellpadding="0" cellspacing="1"
				bgcolor="#a8c7ce">

				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td align="right" width="15%">
						角色名:
					</td>
					<td width="35%">
						<input type="text" name="name" id="_name" size="30" />
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td align="right">
						角色备注:
					</td>
					<td colspan="3">
						<textarea rows="6" cols="100%" name="remark" id="_remark"
							></textarea>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td align="right">
						角色描述:
					</td>
					<td colspan="3">
						<textarea rows="6" cols="100%" name="description"
							id="_description"></textarea>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" class="STYLE19">
					<td colspan="4" align="center">
						<input type="button" class="button2" value="添加" onclick="save_to_role();"
							 />
						<input type="reset" class="button2" value="重置" />
						<input type="button" class="button2" value="返回"
							onclick="javascript:history.go(-1);" />
					</td>
				</tr>
			</table>
		</form>
	</body>
	<script type="text/javascript">
		function save_to_role() {
			var name = $('#_name').val();
			if(!utils_stringLength(name, '角色名', 2, 20))
				return;
			var remark = $('#_remark').val();
			if(!utils_stringLength(remark, '角色备注', 2, 1000))
				return;
			var description = $('#_description').val();
			if(!utils_stringLength(description, '角色描述', 2, 1000))
				return;
			$.ajax({
	   			type: "POST",
	   			url: "${pageContext.request.contextPath}/admin/role/add",
	   			data: $('#_form').serialize(),
	   			dataType: "json",
	   			success: function(json){
     					if(json.id > 0) {
     						window.location.href="${pageContext.request.contextPath}/admin/role/list?id="+json.id+"&url=info";
     					} else {
     						alert('添加用户失败，请重试！');
     					}
   				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
   						alert("操作时发生了错误，请重试");
					},
				});
		}
	</script>
</html>
